package com.wc.alorithm_luogu._前缀和与差分.聪明的质监员;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/1/9 15:14
 * @description https://www.luogu.com.cn/problem/P1314
 */
public class Main {
    /**
     * 思路：前缀和 + 二分
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[] w = new int[N], v = new int[N];
    static long[] sw = new long[N], sv = new long[N];
    static int[] l = new int[N], r = new int[N];
    static int n, m;
    static long s;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        s = sc.nextLong();
        for (int i = 1; i <= n; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        for (int i = 1; i <= m; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }
        int l = 0, r = (int) 1e6;
        long res = Long.MAX_VALUE;
        while (l < r) {
            int mid = l + r + 1 >> 1;
            long sum = cal(mid);
            res = Math.min(res, Math.abs(sum - s));
            if (sum >= s) l = mid;
            else r = mid - 1;
        }
        out.println(Math.min(res, Math.abs(cal(l) - s)));
        out.flush();
    }

    static long cal(int W) {
        for (int i = 1; i <= n; i++) {
            sw[i] = sw[i - 1];
            sv[i] = sv[i - 1];
            if (w[i] >= W) {
                sw[i]++;
                sv[i] += v[i];
            }
        }
        long sum = 0;
        for (int i = 1; i <= m; i++) {
            sum += (sw[r[i]] - sw[l[i] - 1]) * (sv[r[i]] - sv[l[i] - 1]);
        }
        return sum;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

